import Vue from 'vue'
import Router from 'vue-router'

import pageSingle from '@/views/generation/pageSingle'
import dbConfig from '@/views/dbConfig'
import test from '@/views/test/test'
import batchTable from '@/views/generation/batchTable'

Vue.use(Router)

// 路由配置，采用约定，views下一级目录为模块目录，新建一个页面
const files = require.context('.', false, /\.js$/)
const modules = {}

files.keys().forEach(key => {
  if (key === './index.js') return
  modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
})

export default new Router({
  routes: [
    {
      path: '/',
      name: 'pageSingle',
      component: pageSingle
    },
    {
      path: '/db_config',
      name: 'dbConfig',
      component: dbConfig
    },
    {
      path: '/test',
      name: 'test',
      component: test
    },
    {
      path: '/batch_table',
      name: 'batchTable',
      component: batchTable
    }
  ]
})
